<?php

Raise::load('core.ui.RaiseTemplateUIControl');
Raise::load('core.text.html.RaiseHtml');

/**
 * RaiseContentArea UIControl class
 * Creates a UIControl that defines an area of content
 *
 * @author Sam-Mauris Yong / hellclanner at live dot com
 * @license http://www.opensource.org/licenses/bsd-license New BSD License
 * @package phpraise.control
 * @since 1.2
 */
class RaiseContentArea extends RaiseTemplateUIControl{

    /**
     * The CSS class attribute
     * @var string
     */
    private $cssClass;

    /**
     * The content of the content area
     * @var string
     */
    private $content;
    
    public function __construct($ctn) {
        $this->content = $ctn;
        parent::__construct(RaiseHtml::div('{content}', array('id'=>'{id}', 'class'=>'{class}')));
    }
    
    /**
     * Get or set CSS class(es) for this element
     * @params string c (optional) The new CSS class(es)
     * @return string
     */
    public function cssClass($c = null){
        if(func_num_args() == 1){
            $this->cssClass = $c;
        }
        return $this->cssClass;
    }

    /**
     * Get or set the content of the RaiseContentArea
     * @param string $c (optional) New content to set to
     * @return string
     */
    public function content($c = null){
        if(func_num_args() == 1){
            $this->content = $c;
        }
        return $this->content;
    }

    /**
     * Return the final output of the control
     * @return string
     */
    public function output() {
        $this->fields()->add('class', $this->cssClass());
        $this->fields()->add('id', $this->clientId());
        $this->fields()->add('content', $this->content());

        $html = parent::output();
        return $html;
    }
}

